<%@ page language="java" contentType="text/html;charset=UTF-8" pageEncoding="utf-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<html>
<head>
    <title>用户配置界面</title>
    <link type="text/css" rel="stylesheet" href='<spring:url value="/webjars/bootstrap/3.3.5/css/bootstrap.min.css"/>'/>
    <link type="text/css" rel="stylesheet" href='<spring:url value="/webjars/bootstrap/3.3.5/css/bootstrap-theme.min.css"/>'/>
    <link type="text/css" rel="stylesheet" href='<spring:url value="/resources/css/content.css"/>'/>
    <script src='<spring:url value="/webjars/jquery/1.11.1/jquery.min.js"/>'></script>
    <script src='<spring:url value="/webjars/bootstrap/3.3.5/js/bootstrap.js"/>'></script>
    <script src='<spring:url value="/webjars/angularjs/1.5.5/angular.min.js"/>'></script>
    <script src='<spring:url value="/webjars/angularjs/1.5.5/angular-resource.js"/>'></script>
    <script src='<spring:url value="/webjars/bootbox/4.4.0/bootbox.js"/>'></script>
    <script src='<spring:url value="/resources/js/common/pageUtil.js"/>'></script>
    <script src='<spring:url value="/resources/js/gwUser/GWUserModel.js"/>'></script>
    <script src='<spring:url value="/resources/js/gwUser/GWUserService.js"/>'></script>
    <script src='<spring:url value="/resources/js/gwUser/GWUserController.js"/>'></script>
</head>
<body ng-app="gwUserApp" ng-controller="gwUserCtrl">

<div class="adcc-container">
    <div class="row">
        <div class="col-md-12">
            <ol class="breadcrumb">
                <li class="active">用户管理</li>
                <li class="active">用户配置</li>
            </ol>
            <div class="row">
                <div class="col-md-12">
                    <form class="form-inline">
                        <div class="input-group">
                            <input type="text" class="form-control" id="gwUserName" ng_model='searchName' placeholder="名称">
                        </div>
                        <button type="submit" ng-click="findGWUserByName()" class="btn btn-primary">查询</button>
                        <div style="float: right">
                            <button type="button" class="btn btn-success" ng-click="createGWUser()">新增</button>
                            <button type="button" class="btn btn-info" ng-click="updateUserList()">推送</button>
                            <button type="button" class="btn btn-success" ng-click="downloadUserList()">下载</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
    <table class="table table-bordered table-striped  table-condensed table-hover">
        <thead>
        <tr>
            <th>用户名称</th>
            <th>用户ID</th>
            <th>发送队列</th>
            <th>接收队列</th>
            <th>下行报文</th>
            <th>下行全部转发</th>
            <th>状态</th>
            <th>上/下线</th>
            <th>编辑</th>
            <th>删除</th>
        </tr>
        </thead>
        <tbody>
        <tr ng-repeat="gwUser in gwUserList">
            <td style="vertical-align: middle;width: 16%">{{ gwUser.userName }}</td>
            <td style="vertical-align: middle;width: 16%">{{ gwUser.userId }}</td>
            <td style="vertical-align: middle;width: 16%">{{ gwUser.sendQueueName }}</td>
            <td style="vertical-align: middle;width: 16%">{{ gwUser.recvQueueName }}</td>
            <td style="vertical-align: middle;width: 6%" ng-if="gwUser.downlinkMsg==1">拆分结果</td>
            <td style="vertical-align: middle;width: 6%" ng-if="gwUser.downlinkMsg==0">原始报文</td>
            <td style="vertical-align: middle;width: 6%" ng-if="gwUser.downLinkForward==1">是</td>
            <td style="vertical-align: middle;width: 6%" ng-if="gwUser.downLinkForward==0">否</td>
            <td style="vertical-align: middle;width: 6%" ng-if="gwUser.status==1">上线</td>
            <td style="vertical-align: middle;width: 6%" ng-if="gwUser.status==0">下线</td>
            <td style="vertical-align: middle;width: 6%">
                <button ng-if="gwUser.status==1" class="btn btn-warning btn-xs" ng-click="offline(gwUser)">
                    <span class="glyphicon glyphicon-pencil"></span>&nbsp;&nbsp;下线
                </button>
                <button ng-if="gwUser.status==0" class="btn btn-primary btn-xs" ng-click="online(gwUser)">
                    <span class="glyphicon glyphicon-pencil"></span>&nbsp;&nbsp;上线
                </button>
            </td>
            <td style="vertical-align: middle;width: 6%">
                <button class="btn btn-info btn-xs" ng-click="updateGWUser(gwUser)">
                    <span class="glyphicon glyphicon-pencil"></span>&nbsp;&nbsp;修改
                </button>
            </td>
            <td style="vertical-align: middle;width: 6%">
                <button class="btn  btn-danger btn-xs" ng-click="deleteGWUser(gwUser)">
                    <span class="glyphicon glyphicon-remove"></span>&nbsp;&nbsp;删除
                </button>
            </td>
        </tr>
        </tbody>
    </table>
    <nav style="margin-top: 30px" class="form-inline">
        <ul class="pagination">
            <li id="top" class="input-group">
                <a ng-click="firstPage()">
                    <span>首页</span>
                </a>
            </li>
            <li id="previous" class="input-group">
                <a ng-click="previous()">
                    <span>上一页</span>
                </a>
            </li>
            <li ng-repeat="page in pageList" ng-class="{active: isActivePage(page)}" class="input-group">
                <a ng-click="selectCurrentPage(page)" class="form-control">{{ page }}</a>
            </li>
            <li id="next" class="input-group">
                <a ng-click="next()">
                    <span>下一页</span>
                </a>
            </li>
            <li id="bottom" class="input-group">
                <a ng-click="lastPage()">
                    <span>尾页</span>
                </a>
            </li>
            <li class="input-group">
                <%--可设置默认条数--%>
                <select ng-model="selectPageSize" style="height: 34px;" ng-init="selectPageSize='10'" ng-change="changePageSize(selectPageSize)" class="form-control">
                    <option value="10">10</option>
                    <option value="20">20</option>
                    <option value="50">50</option>
                    <option value="100">100</option>
                </select>
            </li>
        </ul>
    </nav>
</div>

<%--网关用户对话框--%>
<div class="modal fade" id="dialogGWUser" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" style="margin-top: 100px;pxoverflow-y: auto" data-backdrop="static">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 class="modal-title">
                    <span id="glyphicon" class="glyphicon glyphicon-plus" aria-hidden="true"></span>{{title}}
                </h4>
            </div>
            <div class="modal-body">
                <form name="userForm" id="userForm" method="post">
                    <small class="error" ng-show="userForm.update.$error.enable"><span class="font-style"></span></small>
                    <input type="hidden" id="id" name="id" ng-model="gwUser.id">
                    <div class="form-group">
                        <label for="userName">名称</label>
                        <input type="text" class="form-control" name="userName" id="userName" ng-model="gwUser.userName" ng-maxlength="50" ng-pattern="/^[A-Z0-9_-]*$/" ng-blur="checkGWUserName(gwUser.userName)" required placeholder="用户名称">
                        <div class="error" ng-show="userForm.userName.$dirty && userForm.userName.$invalid">
                            <small class="error" ng-show="userForm.userName.$error.pattern">
                                <span class="font-style">请输入大写字母、数字、_、-</span>
                            </small>
                            <small class="error" ng-show="userForm.userName.$error.maxlength">
                                <span class="font-style">最大长度50</span>
                            </small>
                            <small class="error" ng-show="userForm.userName.$error.unique">
                                <span class="font-style">队列名称已存在</span>
                            </small>
                        </div>
                    </div>
                    <div class="form-group">
                        <label>用户ID</label>
                        <input  type="text" class="form-control" name="userId" id="userId" ng-model="gwUser.userId" ng-init="gwUser.userId=''" ng-maxlength="20" ng-pattern="/^[A-Z0-9_-]*$/" ng-blur="checkGWUserId(gwUser.userId)" required placeholder="用户ID">
                        <div class="error" ng-show="userForm.userId.$dirty && userForm.userId.$invalid">
                            <small class="error" ng-show="userForm.userId.$error.pattern">
                                <span class="font-style">请输入大写字母、数字、_、-</span>
                            </small>
                            <small class="error" ng-show="userForm.userId.$error.maxlength">
                                <span class="font-style">最大长度20</span>
                            </small>
                            <small class="error" ng-show="userForm.userId.$error.unique">
                                <span class="font-style">用户ID已存在</span>
                            </small>
                        </div>
                    </div>

                    <div class="form-group">
                        <label>发送队列</label>
                        <select class="form-control" ng-model="gwUser.sendQueueId" ng-init="gwUser.sendQueueId='0'">
                            <option value=0>--</option>
                            <option ng-repeat="x in listQueueForSend" value="{{x.id}}">{{x.name}}</option>
                        </select>
                    </div>

                    <div class="form-group">
                        <label>接收队列</label>
                        <select class="form-control" ng-model="gwUser.recvQueueId" ng-init="gwUser.recvQueueId='0'">
                            <option value=0>--</option>
                            <option ng-repeat="x in listQueueForRecv" value="{{x.id}}">{{x.name}}</option>
                        </select>
                    </div>

                    <div class="form-group">
                        <label>下行报文</label>
                        <select class="form-control" ng-model="gwUser.downlinkMsg" ng-init="gwUser.downlinkMsg='0'">
                            <option value='0'>原始报文</option>
                            <option value='1'>拆分结果</option>
                        </select>
                    </div>
                    <div class="form-group">
                        <label>下行全部转发</label>
                        <select class="form-control" ng-model="gwUser.downLinkForward" ng-init="gwUser.downLinkForward='0'">
                            <option value='0'>否</option>
                            <option value='1'>是</option>
                        </select>
                    </div>
                    <div class="row">
                        <div class="col-md-3 col-md-offset-9">
                            <button type="submit" ng-disabled="userForm.$invalid" ng-click="save(gwUser,userForm.$valid)" class="btn btn-primary">保存</button>
                            <button type="button" ng-click="cancel()" class="btn btn-danger">取消</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
</body>
</html>
